﻿@{
    ViewBag.Title = "修改密码";
    Layout = "~/Views/Shared/_Layout.cshtml";

}
@section Scripts{
    <link rel="stylesheet" type="text/css" href="http://cdn.bootcss.com/Uniform.js/4.2.0/css/default.css">
    <script src="http://apps.bdimg.com/libs/layer.m/1.5/layer.m.js"></script>
    <script type="text/javascript">

      

        $(function () {
            $("#submit").bind("click", Save);

            
        })

        function Save() {
            var password = $("#pwd").val();
            if (password == '') {
                $('#pwd').focus();
                layer.open({
                    content: '请填写原密码',
                    style: 'background:rgba(0,0,0, .6); color:#fff; border:none;',
                    time: 2,
                    shade: false
                });
                return false;
            }
            var password1 = $('#pwd1').val();
            if (password1 == '') {
                $('#pwd1').focus();
                layer.open({
                    content: '请输入新密码',
                    style: 'background:rgba(0,0,0, .6); color:#fff; border:none;',
                    time: 2,
                    shade: false
                });
                return false;
            }


            var reg = /^\w{4,10}$/;
            var flag = reg.test(password1);
            if (flag == false) {

                $('#pwd1').focus();
                layer.open({
                    content: '新密码必须由 4-10位字母、数字、组成.',
                    style: 'background:rgba(0,0,0, .6); color:#fff; border:none;',
                    time: 2,
                    shade: false
                });
                return false;
            }

            var password2 = $('#pwd2').val();
            if (password2 != password1) {
                $('#pwd2').focus();
                layer.open({
                    content: '二次密码不一样！',
                    style: 'background:rgba(0,0,0, .6); color:#fff; border:none;',
                    time: 2,
                    shade: false
                });
                return false;
            }
            var data = $('#form1').serializeArray();
            $.post(
                '/Role/UpdatePwd',
                data,
                function (res) {

                    layer.open({
                        content: res.Message,
                        style: 'background:rgba(0,0,0, .6); color:#fff; border:none;',
                        time: 2,
                        shade: false
                    });
                    if (res.State == true)
                        setTimeout(" location.reload()", 2000);
                },
                'json'
            );
            return false;
        }

    </script>
}
<div class="row">
    <div class="col-lg-12">
        <div class="row">
            <div class="col-lg-12">
                <div class="main-box">
                    <header class="main-box-header clearfix">
                        <h2>修改密码</h2>
                    </header>

                    <div class="main-box-body clearfix">
                        <form class="form" id="form1" method="post" action="">
                            <div id="login-box-inner">
                              
                                <div class="input-group">
                                    <span class="input-group-addon"><i class="fa fa-lock"></i></span>
                                    <input type="password" id="pwd" name="pwd" class="form-control" placeholder="请输入原始密码">
                                </div>
                                    
                                    <div class="input-group">
                                        <span class="input-group-addon"><i class="fa fa-lock"></i></span>
                                        <input type="password" id="pwd1" name="pwd1" class="form-control" placeholder="请输入你要更改的新密码">
                                    </div>
                                    <div class="input-group">
                                        <span class="input-group-addon"><i class="fa fa-unlock-alt"></i></span>
                                        <input type="password" id="pwd2" name="pwd2" class="form-control" placeholder="请再次输入你的新密码">
                                    </div>
                                  <br />
                                    <div class="row">
                                        <div class="col-xs-12">
                                            <button type="submit" id="submit" class="btn btn-success btn-lg col-xs-12">
                                                &nbsp; &nbsp; 保存&nbsp; &nbsp;
                                            </button>
                                            
                                        </div>
                                    </div>
                              
                            </div>

                            
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
